package com.lemon.exam.controller;

import com.lemon.exam.common.annotation.Web;
import com.lemon.exam.common.web.Result;
import com.lemon.exam.entity.dto.PaperAnswerDTO;
import com.lemon.exam.entity.vo.PaperAnswerVO;
import com.lemon.exam.entity.vo.PaperVO;
import com.lemon.exam.service.IPaperAnswerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * 试卷-答案表 控制器
 *
 * @author Lemon
 * @since 2025/05/17 10:51:17
 */
@RestController
@RequestMapping("paperAnswer")
@Tag(name = "试卷-答案表管理", description = "试卷-答案表 API")
@Web(childUri = "paperAnswer", childComponent = "system/PaperAnswer.vue")
public class PaperAnswerController {
    @Resource
    private IPaperAnswerService paperAnswerService;

    /**
     * 查看所有试卷
     *
     * @param type
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("findPaperList")
    @Operation(summary = "查看所有试卷")
    public Flux<PaperVO> findPaperList(@RequestParam("type") String type, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
        return paperAnswerService.findPaperList(type, pageNum, pageSize);
    }

    /**
     * 查询试卷
     *
     * @return
     */
    @GetMapping(value = "getPaperAnswer/{paperId}")
    @Operation(summary = "查询试卷详情", description = "考试")
    public Mono<Result<PaperAnswerVO>> getPaperAnswer(@PathVariable("paperId") Long paperId) {
        return paperAnswerService.getPaperAnswer(paperId);
    }

    /**
     * 交卷
     *
     * @param param
     * @return
     */
    @PostMapping("answer")
    @Operation(summary = "交卷")
    public Mono<String> answer(@RequestBody PaperAnswerDTO param) {
        return paperAnswerService.answer(param);
    }
}
